﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminSite.Master" AutoEventWireup="true" CodeBehind="ChooseProduct.aspx.cs" Inherits="Agents.Admin.ChooseProduct" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<asp:Content ID="Header" ContentPlaceHolderID="Header" runat="server">
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <h1>
        בחר מוצר קיים
    </h1>            
    <hr />    
    <asp:ScriptManager ID="ScriptManager1" runat="server" />      
    
     סינון לפי שם: <asp:TextBox ID="txtProductName" runat="server" />
    <asp:Button ID="btnFilter" runat="server" UseSubmitBehavior="true" Text="סנן"
        OnClick="btnFilter_Click" CssClass="button"/> 
    <asp:DataGrid runat="server" ID="DataGridProjects" AutoGenerateColumns="False"
            AllowPaging="True" PageSize="12" PagerStyle-Mode="NumericPages" 
            BackColor="White" BorderStyle="None" 
            CellPadding="3" GridLines="Both" oneditcommand="DataGridProjects_EditCommand1" 
            onpageindexchanged="DataGridProjects_PageIndexChanged" 
            ondeletecommand="DataGridProjects_DeleteCommand"
            onsortcommand="DataGridProjects_SortCommand"
            CssClass="dataGrid" Font-Names="Verdana" BorderColor="#999999" 
        BorderWidth="1px" onitemdatabound="DataGridProjects_ItemDataBound">
        <AlternatingItemStyle BackColor="#DCDCDC" />
        <Columns>
            <asp:BoundColumn DataField="ProductId" Visible="false" />
            <asp:BoundColumn DataField="Name" HeaderText="שם" HeaderStyle-Width="50%" ItemStyle-Width="50%" FooterStyle-Width="50%" SortExpression="Name"/>
            <asp:BoundColumn DataField="Price" HeaderText="מחיר" DataFormatString="{0:F2}"
                HeaderStyle-Width="10%" ItemStyle-Width="10%" FooterStyle-Width="10%" SortExpression="Price"/>
            <asp:BoundColumn DataField="CategoryName" HeaderText="קטגוריה" HeaderStyle-Width="20%" ItemStyle-Width="20%" FooterStyle-Width="20%" SortExpression="CategoryID"/>
            <asp:ButtonColumn CommandName="Edit" HeaderText="עריכת מוצר" Text="עריכה" HeaderStyle-Width="10%" ItemStyle-Width="10%" FooterStyle-Width="10%"/>
            <asp:TemplateColumn HeaderText="מחיקת מוצר" HeaderStyle-Width="10%" ItemStyle-Width="10%" FooterStyle-Width="10%">
                <ItemTemplate>
                    <asp:LinkButton ID="deleteBtn" Text="מחק" CommandName="Delete" runat="server" />
                    <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
                                    TargetControlID="deleteBtn" DisplayModalPopupID="modalPopUp" />
                    <asp:Panel ID="popup" runat="server" CssClass="popup">
                        <table>
                            <tr><td colspan="2">האם אתה בטוח שברצונך למחוק את המוצר?</td></tr>
                            <tr>
                                <td><asp:Button ID="ok" Text="כן" runat="server" CssClass="button" /></td>
                                <td><asp:Button ID="cancel" Text="לא" runat="server" CssClass="button" /></td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <ajaxToolkit:ModalPopupExtender ID="modalPopUp" CancelControlID="cancel" PopupControlID="popup"
                        OkControlID="ok" runat="server" TargetControlID="deleteBtn" />
                </ItemTemplate>
            </asp:TemplateColumn>
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <ItemStyle BackColor="White" ForeColor="Black" />
        <PagerStyle Mode="NumericPages" BackColor="#999999" ForeColor="Black" HorizontalAlign="Center"></PagerStyle>
        <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
    </asp:DataGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AgentConnectionString %>" 
        SelectCommand="SELECT [Products].[Id] AS ProductId, [Products].[Name], [Price], [Categories].[Name] AS CategoryName 
            FROM [Products] JOIN [Categories] 
            ON ([Products].[CategoryId] = [Categories].[Id]) 
            ORDER BY [Name]">
    </asp:SqlDataSource>
    <br />           
    <hr />
    <div class="alignCenter">
        <asp:Button ID="backBtn" Text="חזור" runat="server" onclick="backBtn_Click" CssClass="button"/>
    </div>                    
</asp:Content>
